const Mock = require('mockjs');
const jwt = require('jsonwebtoken');

let data = Mock.mock({
    "list|4":[{
        "id|+1":1,
        "user":"@cname",
        "Euser":"@name",
        "sex|1":['男','女'],
        "date":"@date",
        "flag":false,
    }]
})
let token = 'Bearer ' + jwt.sign({ foo: 'bar' }, 'shhhhh');
module.exports = {
    //...
    devServer: {
        compress: true,
        port: 9000,
        hot:true,
        before(app){
            app.get('/api/Login',(req,res)=>{
                let { user , pwd } = req.query;
                if(user === '666' && pwd === '666'){
                    res.send({
                        code:200,
                        message:'登录成功',
                        token : token,
                        user : user
                    })
                }else{
                    res.send({
                        code:500,
                        message:'登录失败',
                    })
                }
            })

            app.get('/api/list',(req,res)=>{
                res.send(data.list)
            })
        }
    },
};